package cn.chen.proxy.cglibproxy;

import cn.chen.proxy.jdk.UserMgr;
import cn.chen.proxy.jdk.UserMgrImpl;
import net.sf.cglib.proxy.Enhancer;

public class TestCglib {

    public static void main(String[] args) {
        TransCglibProxy proxy =new TransCglibProxy();
        //委托类
        UserMgr userMgr = new UserMgrImpl();

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(userMgr.getClass());
        enhancer.setCallback(proxy);

        //代理类
        UserMgr proxyUser = (UserMgr) enhancer.create();
        proxyUser.addUser();
    }

}
